package com.mrd.grpc;

import com.mrd.proto.*;
import io.grpc.stub.StreamObserver;

/**
 * @author jack
 * @data 2019/5/10 17:10
 */
public class StudentServiceImpl extends StudentServiceGrpc.StudentServiceImplBase {

    @Override
    public void getRealNameByUsername(MyRequest request, StreamObserver<MyResponse> responseObserver) {
        System.out.println("接受的客户端信息：" + request.toString());

        responseObserver.onNext(MyResponse.newBuilder().setRealname("jack").build());
        responseObserver.onCompleted();

    }


    @Override
    public void getStudentsByage(StudentRequest request, StreamObserver<StudentResponse> responseObserver) {
        System.out.println("接受的客户端信息：" + request.getAge());

        responseObserver.onNext(StudentResponse.newBuilder().setName("jack ").setAge(20).setCity("亚洲").build());
        responseObserver.onNext(StudentResponse.newBuilder().setName("tom ").setAge(20).setCity("南极").build());
        responseObserver.onNext(StudentResponse.newBuilder().setName("delasi ").setAge(20).setCity("北美洲").build());
        responseObserver.onCompleted();

    }
}
